package com.yang.jpa.dao;

import com.yang.jpa.model.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RoleDao extends JpaRepository<Role, Integer>, JpaSpecificationExecutor<Role> {

    @Query(value = "select r.* from `role` r inner join staff_role sr on r.id = sr.role_id where sr.staff_id = ?", nativeQuery = true)
    List<Role> findStaffRole(Integer staffId);

}
